package com.zbu.demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:访问类变量
 * User: 86183
 */
class Student {
    //成员变量
    public String name;
    public String gender;
    public int age;
    static String className;
    //成员方法
    public void doClass(){
        System.out.println("按时上课，不要迟到");
    }
    public void doHomework(){
        System.out.println("及时完成作业");
    }
    public void exam(){
        System.out.println("认真考试");
    }
}
public class Test3 {
    public static void main(String[] args) {

        //访问public修饰的类变量
        //通过类名来访问
        Student.className = "1班";
        //通过对象的引用来访问
        Student student = new Student();
        student.className = "1班";

    }
}
